﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DataInterface_BaseDataDownLoad : System.Web.UI.Page, ICallbackEventHandler
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    public string result;
    protected void Page_Load(object sender, EventArgs e)
    {
        Check.CheckPermission("800100");
    }
    public void RaiseCallbackEvent(string eventArgument)
    {
        if (!Check.CheckPermission("800100", "00007"))
        {
            result = "无权操作";
            return;
        }
        try
        {
            BLL.Jet j = new BLL.Jet();
            result = j.P_GetProductArchive(System.Configuration.ConfigurationSettings.AppSettings["erpdb"].ToString(), eventArgument, System.Configuration.ConfigurationSettings.AppSettings["ckdm"].ToString(), System.Configuration.ConfigurationSettings.AppSettings["kwdm"].ToString()) == true ? "1" : "错误";
        }
        catch(Exception ex)
        {
            result = "意外发生";
        }

    }

    public string GetCallbackResult()
    {
        return result;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (!Check.CheckPermission("800100", "00007"))
        {
            Share.Alert(Page, "无权操作!");
        }
        else
        {
            if (new BLL.Jet().SalesUpCheck())
            {
                Share.Alert(Page, "有未上传业务数据,请先上传再同步库存");
            }
            else
            {
                string ProName = "";
                if (ConfigurationManager.AppSettings["DX"].ToString() == "0")
                {
                    ProName = "P_GetProductArchive_SPKCB";
                }
                else
                {
                    ProName = "P_GetProductArchive_SPKCBFORDX";
                }
                if (new BLL.Jet().P_GetProductArchive_SPKCB(System.Configuration.ConfigurationSettings.AppSettings["erpdb"].ToString(), "spkcb", System.Configuration.ConfigurationSettings.AppSettings["ckdm"].ToString(), System.Configuration.ConfigurationSettings.AppSettings["kwdm"].ToString(), ProName))
                {
                    Share.InsertLog("800100", "00007");
                    Share.Alert(Page, "下载成功");


                }
                else
                {
                    Share.Alert(Page, "下载失败");
                }
            }
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (!Check.CheckPermission("800100", "00007"))
        {
            Share.Alert(Page, "有未上传业务数据,请先上传再同步库存");
        }
        else
        {
            if (new BLL.Jet().P_GetVIPInfo_Down(System.Configuration.ConfigurationSettings.AppSettings["erpdb"].ToString(), ""))
            {
                Share.InsertLog("800100", "00007");
                Share.Alert(Page, "下载成功");
            }
            else
            {
                Share.Alert(Page, "下载失败");
            }
        }
    }
}

